
    /**
     * 
     * @param {*} url    链接
     * @param {*} params    参数
     * @param {*} header 需不需要请求头
     * 
     */
    function get(url, params, header) {
       new Promise((resolve, reject) => {
            const xhr = new XMLHttpRequest
            xhr.onreadystatechange = () => {
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        let res = JSON.parse(xhr.responseText)
                        resolve(res)
                    } else {
                        reject(xhr.status)
                    }
                }
            }
            xhr.open('get',`${url}?${params}`)
            header(xhr)
            xhr.send(null)
        }
        )

        p.then(
            res => {
                console.log(res);
            }, err => {
                console.log(err);
            }
        )
            .finally(() => {
                console.log('无条件走一遍');
            })
    }
    /////////////////////
    function post(url, params, header) {
        new Promise((resolve, reject) => {
            const xhr = new XMLHttpRequest
            xhr.onreadystatechange = () => {
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        let res = JSON.parse(xhr.responseText)
                        resolve(res)
                    } else {
                        reject(xhr.status)
                    }
                }
            }
            xhr.open('post',url)
            header(xhr)
            xhr.setRequestHeader('content-type','application/x-www-form-urlencoded')
            xhr.send(params)
        }
        )

        p.then(
            res => {
                console.log(res);
            }, err => {
                console.log(err);
            }
        )
            .finally(() => {
                console.log('无条件走一遍');
            })
    }
